import junit.framework.TestCase;

public class SecurityManagerTest extends TestCase {
	public void testAddUser() {
		SecurityManager sm = new SecurityManager();
		String name = "peanut";
		User user = new User(name, "brittle");
		sm.addUser(user);
		assertEquals(user, sm.findUser(name));
	}
	
	public void testDoLogin() {
		SecurityManager sm = new SecurityManager();
		
		String goodUserName = "peanut", goodUserPassword = "brittle";
		User goodUser = new User(goodUserName, goodUserPassword);
		sm.addUser(goodUser);
		
		String badUserName = "hello", badUserPassword = "goodbye";
		
		assertEquals(PasswordResponse.BAD_UID, sm.doLogin(null, null));
		assertEquals(PasswordResponse.BAD_UID, sm.doLogin(badUserName, badUserPassword));
		assertEquals(PasswordResponse.GOOD_LOGIN, sm.doLogin(goodUserName, goodUserPassword));
		assertEquals(PasswordResponse.BAD_PASSWORD, sm.doLogin(goodUserName, badUserPassword));
	}
}
